package com.example.ispy;

import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;

public class AlertDialogFragment extends DialogFragment implements DialogInterface.OnClickListener{

	public static AlertDialogFragment newInstance(String message) {
		AlertDialogFragment adf = new AlertDialogFragment();
	    Bundle bundle = new Bundle();
	    bundle.putString("alert-message",message);
	    adf.setArguments(bundle);
		return adf;	    
	}

	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.setCancelable(true);	    
		int style = DialogFragment.STYLE_NORMAL, theme = 0;	    
		setStyle(style,theme);
	}

	@Override
	public Dialog onCreateDialog(Bundle savedInstanceState)	
	{
		AlertDialog.Builder b = new AlertDialog.Builder(getActivity())
		.setMessage(this.getArguments().getString("alert-message"));
		
		return b.create();	    
	}
 
	public void onClick(DialogInterface dialog, int which)	    
	{
		dismiss();
	}
}	
